/*
 * @Author: alan_mf
 * @Date: 2023-03-07 21:05:23
 * @LastEditors: upp24 1246815351@qq.com
 * @LastEditTime: 2023-07-21 16:34:28
 * @FilePath: /pure-admin-thin-i18n/src/api/routes.ts
 * @Description:
 *
 */
import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";
export type BannerResult = {
  page: number;
  pagesize: number;
  success: boolean;
  code: number;
  token: string;
  msg: string;
  data: {
    data: any[];
    total: number;
    page: number;
    pagesize: number;
  };
};
//获取路由列表
export const getAsyncRoutes = (data) => {
  return http.request<BannerResult>("get", baseUrlApi(`admin/auth/role/myRoute?role_id=${data.role_id}&role_name=${data.role_name}`), {
  });
};
//获取路由列表
export const getAsyncRoutesInfo= (data?: object) => {
  return http.request<BannerResult>("post", baseUrlApi("auth/role/myRoute"), {
    data
  });
};
//获取全部路由列表
export const getAsyncAllRoutes = (data?: object) => {
  return http.request<BannerResult>("get", baseUrlApi("admin/auth/route/list"), {
    data
  });
};
//添加路由
export const addAsyncRoutes = (data?: object) => {
  return http.request<BannerResult>("post", baseUrlApi("admin/auth/route/insert"), {
    data
  });
};
// 修改路由
export const updateRoutes = (data?: object) => {
  return http.request<BannerResult>("post", baseUrlApi("admin/auth/route/update"), {
    data
  });
};


//删除路由
export const delAsyncRoutes = (data?: object) => {
  return http.request<BannerResult>("post", baseUrlApi("admin/auth/route/delete"), {
    data
  });
};
// 角色删除
export const delAsyncRole = (data?: object) => {
  return http.request<BannerResult>("post", baseUrlApi("admin/auth/role/delete"), {
    data
  });
};
//更新路由
export const updateAsyncRoutes = (data?: object) => {
  return http.request<BannerResult>("post", baseUrlApi("auth/role/assign"), {
    data
  });
};


// 角色列表
export const roleList = (data?: object) => {
  return http.request<BannerResult>("get", baseUrlApi(`admin/auth/role/list?role_name=${data.role_name}`), {
    data
  });
};

// 角色添加
export const addRoleInsert= (data?: object) => {
  return http.request<BannerResult>("post", baseUrlApi(`admin/auth/role/insert`), {
    data
  });
};

// 角色修改
export const updateRole= (data?: object) => {
  return http.request<BannerResult>("post", baseUrlApi(`admin/auth/role/update`), {
    data
  });
};

// 分配路由
export const roleAssign= (data?: object) => {
  return http.request<BannerResult>("post", baseUrlApi(`admin/auth/role/assign`), {
    data
  });
};
